//
// Created by francklinson on 2021/5/27.
//
#include <vector>
#include <iostream>

using namespace std;

class Solution {
public:
    int minOperations(vector<int> &nums) {
        // 修改数组 后一个比前面的大1即可
        int ans = 0;
        for (int i = 1; i < nums.size(); ++i) {
            if (nums[i] > nums[i - 1]) continue;
            else {
                ans += nums[i - 1] + 1 - nums[i];
                nums[i] = nums[i - 1] + 1;
            }
        }
        return ans;
    }
};

int main() {
    vector<int> v{1, 5, 2, 4, 1};
    Solution sol;
    cout << sol.minOperations(v) << endl;
    return 0;

}